package com.cfoco.test;

import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl;
import cn.afterturn.easypoi.util.PoiPublicUtil;
import org.apache.commons.collections4.SetValuedMap;

import java.util.Map;

/**
 * @author syd
 * @create 2020-09-07 22:16
 */
public class MapImportHandler extends ExcelDataHandlerDefaultImpl<Map<String,Object>> {

    @Override
    public void setMapValue(Map<String, Object> map, String originKey, Object value) {
        if(value instanceof Double){
            map.put(getRealKey(originKey), PoiPublicUtil.doubleToString((Double) value));
        }else{
            map.put(getRealKey(originKey),value!=null?value.toString():null);
        }
        super.setMapValue(map, originKey, value);
    }

    private String getRealKey(String originKey) {
        if(originKey.equals("交易账户")){
            return "accountNo";
        }
        if(originKey.equals("姓名")){
            return "name";
        }
        if(originKey.equals("客户类型")){
            return "type";
        }
        return originKey;
    }
}
